home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-17 | 3.7 KB | 168 lines | [TEXT/CWIE] |
- // BoundMethod.h
-
- #ifndef BoundMethod_h
- #define BoundMethod_h
-
- #ifndef Procedure_h
- #include "Procedure.h"
- #endif
- #ifndef Integers_h
- #include "Integers.h"
- #endif
-
- template < class TargetType >
- class BoundMethod: public Procedure
- {
- typedef void (TargetType::*MemberType)();
-
- private:
- TargetType *target;
- MemberType method;
-
- public:
- BoundMethod( TargetType *theTarget, MemberType theMethod )
- : target( theTarget ),
- method( theMethod )
- {}
-
- TargetType *Target() const { return target; }
- MemberType Method() const { return method; }
-
- void SetTarget( TargetType *t ) { target = t; }
- void SetMethod( MemberType m ) { method = m; }
-
- bool Null() const { return target == 0 || method == 0; }
-
- virtual void operator()() const
- {
- if ( !Null() )
- (target->*method)();
- }
- };
-
- template < class TargetType,
- class P0 >
- class BoundMethod1: public Procedure1< P0 >
- {
- typedef void (TargetType::*MemberType)( P0 );
-
- private:
- TargetType *target;
- MemberType method;
-
- public:
- BoundMethod1( TargetType *theTarget, MemberType theMethod )
- : target( theTarget ),
- method( theMethod )
- {}
-
- TargetType *Target() const { return target; }
- MemberType Method() const { return method; }
-
- void SetTarget( TargetType *t ) { target = t; }
- void SetMethod( MemberType m ) { method = m; }
-
- bool Null() const { return target == 0 || method == 0; }
-
- virtual void operator()( P0 p0 ) const
- {
- if ( !Null() )
- (target->*method)( p0 );
- }
- };
-
- template < class TargetType,
- class P0, class P1 >
- class BoundMethod2: public Procedure2< P0, P1 >
- {
- typedef void (TargetType::*MemberType)( P0, P1 );
-
- private:
- TargetType *target;
- MemberType method;
-
- public:
- BoundMethod2( TargetType *theTarget, MemberType theMethod )
- : target( theTarget ),
- method( theMethod )
- {}
-
- TargetType *Target() const { return target; }
- MemberType Method() const { return method; }
-
- void SetTarget( TargetType *t ) { target = t; }
- void SetMethod( MemberType m ) { method = m; }
-
- bool Null() const { return target == 0 || method == 0; }
-
- virtual void operator()( P0 p0, P1 p1 ) const
- {
- if ( !Null() )
- (target->*method)( p0, p1 );
- }
- };
-
- template < class TargetType,
- class P0, class P1, class P2 >
- class BoundMethod3: public Procedure3< P0, P1, P2 >
- {
- typedef void (TargetType::*MemberType)( P0, P1, P2 );
-
- private:
- TargetType *target;
- MemberType method;
-
- public:
- BoundMethod3( TargetType *theTarget, MemberType theMethod )
- : target( theTarget ),
- method( theMethod )
- {}
-
- TargetType *Target() const { return target; }
- MemberType Method() const { return method; }
-
- void SetTarget( TargetType *t ) { target = t; }
- void SetMethod( MemberType m ) { method = m; }
-
- bool Null() const { return target == 0 || method == 0; }
-
- virtual void operator()( P0 p0, P1 p1, P2 p2 ) const
- {
- if ( !Null() )
- (target->*method)( p0, p1, p2 );
- }
- };
-
- template < class TargetType,
- class P0, class P1, class P2, class P3 >
- class BoundMethod4: public Procedure4< P0, P1, P2, P3 >
- {
- typedef void (TargetType::*MemberType)( P0, P1, P2, P3 );
-
- private:
- TargetType *target;
- MemberType method;
-
- public:
- BoundMethod4( TargetType *theTarget, MemberType theMethod )
- : target( theTarget ),
- method( theMethod )
- {}
-
- TargetType *Target() const { return target; }
- MemberType Method() const { return method; }
-
- void SetTarget( TargetType *t ) { target = t; }
- void SetMethod( MemberType m ) { method = m; }
-
- bool Null() const { return target == 0 || method == 0; }
-
- virtual void operator()( P0 p0, P1 p1, P2 p2, P3 p3 ) const
- {
- if ( !Null() )
- (target->*method)( p0, p1, p2, p3 );
- }
- };
-
- #endif
-